module JuliaSet

include("utils/utils.jl")
using .Utils

using Base.Iterators

export initMap
export initMapValue
export iterateMap

X_MIN = -2.0
X_MAX = 2.0
Y_MIN = -2.0
Y_MAX = 2.0

THRESHOLD = 2


function initMap(size:: Int64) :: Array{Complex{Float64}, 2}
    map = Array{Complex{Float64}}(undef, size, size)
    initMapValue(map)
    return map
end


"""
Initialize the value of a given map
"""
function initMapValue(map :: Array{Complex{Float64}})
    map_size = size(map)[1]
    for i in 1:map_size
        for j in 1:map_size
            map[i, j] = pixelValue(map_size, X_MIN, X_MAX, Y_MIN, Y_MAX, j, i)
        end
    end
    
end

"""
Iterate the map for one step given step function f

"""
function iterateMap(f, map::Array{Complex{Float64}, 2})
    for i in 1:size(map)[1]
        for j in 1:size(map)[2]
            map[i, j] = f(map[i, j])
        end
    end
    
end

end